﻿using System;
using UnityEngine;

public class SpawnOnDestroy : MonoBehaviour
{
    protected static bool applicationIsQuitting;
    public Component target;

    protected virtual void OnApplicationQuit()
    {
        applicationIsQuitting = true;
    }

    private void OnDestroy()
    {
        if (!applicationIsQuitting)
        {
            this.target.Spawn<Component>(base.transform.position, base.transform.rotation);
        }
    }
}

